-----------------------------------------------------------------------------------------------------
      name:  explore
       log:  C:\Users\wb545489\OneDrive - WBG\Personal\R&R - Final\Replication-ISQ\Explore_20200126.l
> og
  log type:  text
 opened on:  26 Jan 2020, 14:40:23

. 
. 
. * Excel file needs manual correction: month = 11 is repeated in 2016, second should be 12
. import excel "dataset_exp_stata.xlsx", sheet("Data") firstrow 
(25 vars, 154 obs)

. gen t = ym(year(date),month(date))

. format %tm t

. tsset t
        time variable:  t, 2005m1 to 2017m10
                delta:  1 month

. 
. * Implement settings (definition grants, sample, frequency, logs, ...)
. 
. gen grants = Grants_Cash

. 
. if $ignorecrisis == 1{
.         keep if t <= 662 // before 2015m4; find numeric value of date with -di monthly("2015m3","YM
> ")-
. }

. 
. 
. if $quarterly == 1{
.         gen yq = qofd(dofm(t))
.         replace t = yq
.         gen quarter = quarter(date)
.         
.         gen ones = 1 // keep only quarters with 3 months available (=potentially drop first 1-2 mon
> ths)
.         bysort t: egen count = sum(ones) 
.         keep if count == 3
.         drop ones count
.         
.         collapse (first) year quarter (sum) grants Grants_Cash exp_cur_tot exp_tot exp_cap_net debt
> _int_total fisc_total NonFisc_Total_nogrants debt_int_centralbank  debt_int_banks debt_int_nonbanks
> , by(t)
.         format %tq t
.         tsset t
.         
. }

. 
. 
. if $takelog == 1{
.         replace grants = log(grants+1)
.         replace exp_cur_tot = log(exp_cur_tot)
.         replace exp_cap_net = log(exp_cap_net)
. }

. 
. *********
. *** DATA
. *********
. 
. * generating total revenue variable
. gen revenue = fisc_total+ NonFisc_Total_nogrants

. label variable revenue "Total revenue"

. 
. * generating 2008 debt write-off dummy
. if $quarterly == 0{
.         gen cbDummy = ( year==2008 & month ==1)
. }

. if $quarterly == 1{
.         gen cbDummy = ( year==2008 & quarter ==1)
. }

. label variable cbDummy "Debt write-off, 2008"

. 
. * generating 2012 debt write-off dummy
. if $quarterly == 0{
.         gen cbDummy2 = ( year==2012 & month ==1)
. }

. if $quarterly == 1{
.         gen cbDummy2 = ( year==2012 & quarter ==1)
. }

. label variable cbDummy2 "Debt write-off, 2012"

. 
. * generating dummy for political crisis
. gen pierre = 0 

. if $quarterly == 0{
.         replace  pierre =1 if t >= ym(2015,4)
(31 real changes made)
. }

. if $quarterly == 1{
.         replace  pierre =1 if t >= yq(2015,1)
. }

. 
. label variable pierre "Crisis"

. 
. * generating trend variable
. gen trend = _n

. label variable trend "Trend"

. 
. * generating first difference of internal debt
. gen Ddebt_int_total = D.debt_int_total
(1 missing value generated)

. label variable Ddebt_int_total "Domestic borrowing"

. 
. * a few more labels
. label variable Grants_Cash  "Grants"

. label variable exp_tot  "Total expenditure"

. 
. * generating first difference of domestic debt to central bank
. gen Ddebt_int_centralbank = d.debt_int_centralbank
(1 missing value generated)

. label variable Ddebt_int_centralbank "DB central bank"

. 
. * generating first difference of domestic borrowing on financial market
. gen debt_finmar = debt_int_banks + debt_int_nonbanks

. gen Ddebt_finmar = d.debt_finmar
(1 missing value generated)

. label variable Ddebt_finmar "DB fin. market"

. 
. * generating squared first difference of domestic borrowing on financial market
. gen Ddebt_finmar_sq = Ddebt_finmar^2 
(1 missing value generated)

. label variable Ddebt_finmar_sq "DB fin. market (sq.)"

. 
. *** Test data for stationarity
. 
. if $takelog == 1 {
.         replace debt_int_total = log(debt_int_total)
. }

. 
. *varsoc debt_int_total, maxlag(6) exog(trend)
. dfuller debt_int_total, lags(2) //regress

Augmented Dickey-Fuller test for unit root         Number of obs   =       151

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)              2.864            -3.493            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 1.0000

. *varsoc Ddebt_int_total, maxlag(6) exog(trend)
. dfuller Ddebt_int_total, trend lags(1) //regress 

Augmented Dickey-Fuller test for unit root         Number of obs   =       151

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -8.540            -4.023            -3.443            -3.143
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.0000

. *varsoc Grants_Cash, maxlag(6) exog(trend)
. dfuller Grants_Cash, lags(1) //regress

Augmented Dickey-Fuller test for unit root         Number of obs   =       152

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -8.428            -3.493            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.0000

. *varsoc revenue, maxlag(6) exog(trend)
. dfuller revenue, lags(3) trend //regress

Augmented Dickey-Fuller test for unit root         Number of obs   =       150

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -4.400            -4.023            -3.443            -3.143
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.0022

. *varsoc exp_tot, maxlag(6) exog(trend)
. dfuller exp_tot, lags(1) trend //regress

Augmented Dickey-Fuller test for unit root         Number of obs   =       152

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -8.631            -4.023            -3.443            -3.143
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.0000

. 
. log close explore
      name:  explore
       log:  C:\Users\wb545489\OneDrive - WBG\Personal\R&R - Final\Replication-ISQ\Explore_20200126.l
> og
  log type:  text
 closed on:  26 Jan 2020, 14:40:25
-----------------------------------------------------------------------------------------------------
